using System;
using UnityEngine;

namespace NodeCanvas.BehaviourTrees
{
	[AddComponentMenu("NodeCanvas/Behaviour Tree Owner")]
	public class BehaviourTreeOwner : GraphOwner
	{
		public BehaviourTree BT;

		public override Graph behaviour
		{
			get
			{
				return BT;
			}
			set
			{
				BT = (BehaviourTree)value;
			}
		}

		public override Type graphType
		{
			get
			{
				return typeof(BehaviourTree);
			}
		}

		public bool runForever
		{
			get
			{
				return !(BT != null) || BT.runForever;
			}
			set
			{
				if (BT != null)
				{
					BT.runForever = value;
				}
			}
		}

		public float updateInterval
		{
			get
			{
				return (!(BT != null)) ? 0f : BT.updateInterval;
			}
			set
			{
				if (BT != null)
				{
					BT.updateInterval = value;
				}
			}
		}

		public Status rootStatus
		{
			get
			{
				return (!(BT != null)) ? Status.Resting : BT.rootStatus;
			}
		}

		public Status Tick()
		{
			if (BT == null)
			{
				Debug.LogWarning("There is no Behaviour Tree assigned", base.gameObject);
				return Status.Resting;
			}
			return BT.Tick(this, base.blackboard);
		}
	}
}
